﻿package Component
{
	import flash.display.MovieClip;
	import Map.MapScreen;
	import Game.ScoreBoard;

	// This object will manage what will be displayed
	public class ScreenSwap
	{

		private var _stage:MovieClip;
		private var current:MovieClip;
		private var _load_screen:LoadScreen;
		public function set load_screen(screen:LoadScreen)
		{
			screen.visible = false;
			_stage.addChild(screen);
			this._load_screen = screen;
		}
		public function get load_screen():LoadScreen
		{
			return _load_screen;
		}

		private var _map:MapScreen;
		public function set map(_map:MapScreen)
		{
			_map.visible = false;
			_stage.addChild(_map);
			this._map = _map;
		}
		public function get map():MapScreen
		{
			return _map;
		}

		private var _score:ScoreBoard;
		public function set score(_score:ScoreBoard)
		{
			_score.visible = false;
			_stage.addChild(_score);
			this._score = _score;
		}
		public function get score():ScoreBoard
		{
			return _score;
		}

		private var _connection_screen:ConnectionScreen;
		public function set connection_screen(_connection_screen:ConnectionScreen)
		{
			_connection_screen.visible = false;
			_stage.addChild(_connection_screen);
			this._connection_screen = _connection_screen;
		}
		public function get connection_screen():ConnectionScreen
		{
			return _connection_screen;
		}

		public function ScreenSwap(_stage:MovieClip)
		{
			this._stage = _stage;
			current = null;
		}

		public function display_load_screen()
		{
			swap(_load_screen);
		}

		public function display_map()
		{
			swap(_map);
		}

		public function display_connection_screen()
		{
			swap(_connection_screen);
		}

		public function display_score_board()
		{
			swap(_score);
		}

		private function swap(target:MovieClip)
		{
			if (current != null)
			{
				current.visible = false;
			}
			current = target;
			target.visible = true;
		}

	}

}